#ifndef __PLUGINMANAGER_H__
#define __PLUGINMANAGER_H__

#include <QObject>
#include <QMap>
#include <QPair>
#include <QDomDocument>


class CPluginProcess;
class CSettings;
class QDomElement;

class CPluginManager: public QObject
{
Q_OBJECT
public:
	static CPluginManager *getPluginManager();

	enum tPluginType
	{
		PLUGIN_TYPE_SCANNER,
		PLUGIN_TYPE_BROWSERS,
		PLUGIN_TYPE_HIGHLIGHT,
		PLUGIN_TYPE_GETTER
	};

	// get and set the library location and plugin directory:
	QString getLibDir() const;
	void setLibDir(const QString &strLibDir);

	QString getPluginDir() const;
	void setPluginDir(const QString &strPluginDir);


	// run several plugins on a single input file:
	// the input file must be identified by a full (absolute) path, the plugin names are
	// listed in the string list:
	//
	// NOTE: The pluginProcess class is created on theheap, and without a parent, since this can be called from a thread.
	// right now the user is responsible for cleaning up the memory used, in but perhaps a better way would be to pass in an
	// optional QOBject ptr to use as the parent?
	CPluginProcess *runScannerPlugins(const QString &strInputFilePath, const QStringList &slPluginNames, const QString &strConfigFile = QString());

	// scan for, and load plugins:
	void scanPlugins();

	// get a list of plugin names by type:
	QStringList getPluginNames(tPluginType nType) const;

	// get default config for this plugin:
	CSettings getDefaultConfig(tPluginType nType, const QString &strName) const;

	QString getPluginDescription(const QString &strPluginName) const;
	QString getPluginType(const QString &strPluginName) const;


	QString getPluginConfig() const;
private:
		CPluginManager();

	void addPlugin(const QDomElement &pluginXML);

	QMap<QString,QPair<QString,QString> > m_pluginDetails;

	QString m_strPluginDir;
	QString m_strLibDir;

	QDomDocument m_pluginConfig;
};

#endif
